#!/usr/bin/python


from itertools import groupby
import os

"""
This file is used to separate chains in a PDB file into separate files.
For instance, if a PDB file called 1A3N.pdb contains 4 separate chains A, B, C, D, this
program will separate each of the chain into a different file and each file will only contain
the data for the chain it represents.
The files created will be:
1A3N_A.pdb - Will data of contain atoms belonging to chain A
1A3N_B.pdb - Will data of contain atoms belonging to chain B
1A3N_C.pdb - Will data of contain atoms belonging to chain C
1A3N_D.pdb - Will data of contain atoms belonging to chain D
"""

"""
The following file (.txt extension assumed) contains a list of PDB files whose
   chains needed to be separated.
The files are assumed to be already downloaded and be stored in [FILE_NAME_files]/[PDB file name such as 1A3N].pdb
If there is a an argument provided to main, such as "transient", it will override the value set here.
"""

def filter_cities (l):
	v = l.split (',')
	
	if (len (v[4]) > 0) and (v[4] != "Population"):
		return int (v[4]) > 50000
		
	return False;

def main (arg = None):

	with open ("worldcitiespop.csv", "r", encoding="latin1") as input:

		atoms = list(filter (filter_cities, input))

		for val in atoms:

			print(val.strip())


if __name__ == '__main__':
  main()